<template>
	<view class="pageBox">
		<loading v-if="loading"></loading>
		<view v-else>
			
		
		<view class="title">
			<view class="item" @click="shareType(1)">
				<image src="https://imgs.ynz666.com/2025/05/15/MDk1ZWZlNGI1YTM1ZWM5OTRjZmExMjIzZDcwNmFkMzE=.png" mode="aspectFill" class="img"></image>
				<view class="item_box">
					<view class="name">
						<text class="text_v1">{{infoData.direct}}</text>
						<text class="text_v2">人</text>
					</view>
					<view class="desc">
						直接分享
					</view>
				</view>
			</view>
			<view class="item" @click="shareType(2)">
				<image src="https://imgs.ynz666.com/2025/05/15/MTM1OGVkYmMxMWUwOTA4ZGM5MmNmZjlhYjdmYmMzZDg=.png" mode="aspectFill" class="img"></image>
				<view class="item_box">
					<view class="name nameT">
						<text class="text_v1">{{infoData.indirect}}</text>
						<text class="text_v2">人</text>
					</view>
					<view class="desc descT">
						间接分享
					</view>
				</view>
			</view>
		</view>
		
		<view class="search-input">
			<view class="search-input-box">
					<image src="../../static/index/search.png" mode="aspectFill" class="img"></image>
					<input type="text" placeholder="昵称/电话" :value="par.search"
						placeholder-style="font-size:28rpx;" @confirm="BindSearchKeyWord" @input="inputAdress" class="inputClass">
			</view>
		</view>
		
		
		<!-- 分类型 -->
		<view class="typeFun">
				 <view :class="navIndex==index?'item item_active':'item'" v-for="(item,index) in categorys" :key="index" @click="navClick(index,item.id)">{{item.name}}</view>
		</view>
		
		<view class="listFun">
			<view class="item" v-for="(item,index) in searchList" :key="index" v-if="searchList.length>0">
				<view class="name">
					昵称：{{item.nickname}}
				</view>
				<view class="identity">
					链接方式：{{item.directType}}
				</view>
				<view class="identity">
					身份：
					<text v-for="(itemB,indexB) in item.identity" :key="indexB">
					 <text class="text_right">{{itemB}}</text>
					 <text class="text_xhx" v-if="indexB!==item.identity.length-1">|</text>
					</text>
				</view>
				<view class="date">
					时间：{{item.createdAt}}
				</view>
			</view>
			<!-- <view class="item_kong" v-if="searchList.length==0">
				当前暂无数据
			</view> -->
		</view>
		
		</view>
		
	</view>
</template>

<script>
	
	var app = getApp();
	import {
		memberTeamCount,memberTeamList
	} from '../../apis/my.js';
	import loading from '../../components/loading/loading.vue';
	export default {
		data() {
			return {
				loading:true,
				
				searchList: [],
				par:{
					page: 1,
					pageSize: 10,
					search: "",
					type:0,
					directType:0,//0-全部(默认)，1-直接推荐，2-间接推荐
				},
				isLastPage: false,
				
				categorys:[
					{
						name:'全部',
						id:0
					},
					{
						name:'用户',
						id:1
					},
					{
						name:'会员',
						id:2
					},
					{
						name:'销氪',
						id:3
					},
					{
						name:'服务商',
						id:4
					},
				],
				navIndex:0,
				
				infoData:{},//分享人数
			}
		},
		components: {
			loading
		},
		onLoad(options) {
			this.memberTeamCountFun();
			this.getSecKillData();
		},
		methods: {
			shareType(index){
				
				if(index==this.par.directType){
					this.par.directType =0
				}else{
					this.par.directType = index;
				}
				
				
				this.searchList = [];
				this.isLastPage = false;
				this.par.page = 1;
				this.getSecKillData()
			},
			memberTeamCountFun(){
				memberTeamCount().then(res=>{
					this.infoData=res.data
					this.loading=false
				})
			},
			getSecKillData() {
				let that = this;
				
				memberTeamList(that.par).then(res=>{
					that.searchList = that.par.page == 1 ? res.data.list : that.searchList.concat(res.data.list);
					that.isLastPage = res.data.lastPage;
				})
			},
			navClick(index,id){
				this.navIndex=index
				this.par.page = 1;
				this.par.type = id;
				this.isLastPage = false;
				this.getSecKillData()
			},
			inputAdress(e) {
				let that = this;
				that.par.search = e.detail.value;
				that.searchList = [];
				if (e.detail.value !== '') {
					that.searchList = [];
					that.isLastPage = false;
					that.par.page = 1;
					that.getSecKillData()
				} else {
					that.searchList = [];
					that.noneFlag = false;
					that.isLastPage = false;
					that.par.page = 1;
				}
			},
			// 确认搜索
			BindSearchKeyWord() {
				let that = this;
				if (that.par.search) {
					that.searchList = [];
					// that.noneFlag = false;
					that.isLastPage = false;
					that.par.page = 1;
					that.getSecKillData()
				}
			},
			GetSearchList() {
				let that = this;
				const params = {
					page: that.currentPage,
					pageSize: that.pageSize,
					keyWord: that.keyWord,
				}
				productSearch(params).then(res => {
					if (res.data.list.length > 0) {
						that.noneFlag = false;
						that.searchList = that.searchList.concat(res.data.list);
						that.isLastPage = res.data.lastPage;
						that.loading = false;
					} else {
						//没有该关键词的信息
						that.noneFlag = true;
					}
				})
			}
		},
		onReachBottom() {
			if (!this.isLastPage) {
				console.log(11)
				this.par.page++;
				this.getSecKillData();
			}
		},
	}
</script>

<style lang="scss">
page {
	background: #f9f9f9;
}
.pageBox{
	width: 100%;
	.title{
		padding: 28rpx 32rpx 0;
		display: flex;
		align-items: center;
		justify-content: space-between;
		.item{
			width: 330rpx;
			height: 180rpx;
			position: relative;
			.img{
				width: 330rpx;
				height: 180rpx;
			}
			.item_box{
				width: 330rpx;
				height: 180rpx;
				position: absolute;
				top: 0;
				.name{
					display: flex;
					align-items: baseline;
					padding: 26rpx 0 10rpx 28rpx;
					color: #BF4F17;
					.text_v1{
						font-weight: 500;
						font-size: 48rpx;
						
					}
					.text_v2{
						font-weight: 500;
						font-size: 28rpx;
					}
				}
				.desc{
					margin: 0 0 0 28rpx;
					width: 152rpx;
					height: 52rpx;
					background: linear-gradient( 226deg, #FFB280 17%, #FF6E3E 100%);
					border-radius: 40rpx 40rpx 40rpx 40rpx;
					font-weight: 500;
					font-size: 24rpx;
					color: #FFFFFF;
					display: flex;
					align-items: center;
					justify-content: center;
				}
				.nameT{
					color: #306CC5;
				}
				.descT{
					background: linear-gradient( 226deg, #80C0FF 9%, #3D88F6 100%);
				}
			}
		}
	}
	// 搜索框
	.search-input {
		padding: 20rpx 0;
		font-size: 28rpx;
		color: #999999;
	
		.search-input-box {
			display: flex;
			justify-content: space-between;
			background: #F1F2F5;
			border-radius: 40rpx;
			width: 690rpx;
			margin: 0 30rpx;
			height: 78rpx;
			line-height: 78rpx;
			align-items: center;
			position: relative;

				.img {
					width: 38rpx;
					height: 38rpx;
					margin: 0 10rpx 0 34rpx;
					position: absolute;
					left: 20rpx;
				}
				.inputClass {
					font-size: 28rpx;
					height: 32rpx;
					color: #333333;
					line-height: 90rpx;
					width: 100%;
					text-align: center;
					height: 78rpx;
				}
		}
	}
	
	.typeFun{
		padding: 0 32rpx 24rpx;
		// display: flex;
		// align-items: center;
		// justify-content: space-between;
		display: -webkit-box;
		overflow-x: auto;
		.item{
			width: 152rpx;
			height: 60rpx;
			border-radius: 40rpx 40rpx 40rpx 40rpx;
			border: 2rpx solid #D8D8D8;
			font-weight: 400;
			font-size: 28rpx;
			color: #727272;
			display: flex;
			align-items: center;
			justify-content: center;
			margin-right: 20rpx;
		}
		.item_active{
			border: 2rpx solid #FF5F25;
			font-weight: bold;
			color: #FF5F25;
		}
	}
	.listFun{
		padding: 0 32rpx;
		.item{
			width: 622rpx;
			height: 146rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			padding: 28rpx 32rpx;
			margin-bottom: 26rpx;
			.name{
				font-weight: 400;
				font-size: 24rpx;
				color: #000000;
			}
			.identity{
				font-weight: 400;
				font-size: 24rpx;
				color: #727272;
				padding: 6rpx 0 0;
			}
			.date{
				font-weight: 400;
				font-size: 22rpx;
				color: #727272;
				padding: 6rpx 0 0;
				width: 100%;
				display: flex;
				justify-content: flex-end;
			}
		}
	}
	
	
}
</style>
